<?php
namespace App\Libs\Base;
use \App\Libs\Menu\Menu;
class BaseSmartyAction extends BaseAction
{
    private $category;
    private $page;
    private $params = array();
    protected function beforeRun() {
        $this->declareView = 'smarty';
    }
    public function setPage($page) {
        $this->page = $page;
    }

    public function setCategory($category) {
        $this->category = $category;
    }

    protected function addParam($name, $value) {
        $this->params[$name] = $value;
    }

    public function execute() {
        
        return \App\Libs\Views\Smarty::view(
            array_merge(
                $this->params,
                array(
                    'islogin' => ! empty($this->session),
                    'username' => ! empty($this->session) ? $this->session->nickname : '',
                )
            ),
            'html/' . $this->category . '/' . $this->page . '.tpl.html',
            'html/' . $this->category . '/base.tpl.html'
        );
    }
}
